package com.wangshouyu.mp.base.response;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;

import java.io.Serializable;
import java.util.Objects;

/**
 * @author 王守钰
 * @date 2020年08月16日 01:08
 * @description: 基本响应结果
 */
public class BaseResponse implements Serializable {

    /**
     * 错误代码
     */
    @SerializedName(value = "errcode")
    @JsonProperty(value = "errcode")
    @JSONField(name = "errcode")
    private int errCode;

    /**
     * 错误消息
     */
    @SerializedName(value = "errmsg")
    @JsonProperty(value = "errmsg")
    @JSONField(name = "errmsg")
    private String errMsg;

    public int getErrCode() {
        return errCode;
    }

    public void setErrCode(int errCode) {
        this.errCode = errCode;
    }

    public String getErrMsg() {
        return errMsg;
    }

    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        BaseResponse that = (BaseResponse) o;
        return errCode == that.errCode &&
                Objects.equals(errMsg, that.errMsg);
    }

    @Override
    public int hashCode() {
        return Objects.hash(errCode, errMsg);
    }

    @Override
    public String toString() {
        return "BaseResponse{" +
                "errCode=" + errCode +
                ", errMsg='" + errMsg + '\'' +
                '}';
    }
}
